import request from '@u/request'
import { HttpMethod } from '@u/http'

// 查询客户管理列表
export function listMember(query) {
  return request({
    url: '/beauty/member/list',
    method: HttpMethod.GET,
    params: query
  })
}

// 查询客户管理详细
export function getMember(id) {
  return request({
    url: '/beauty/member/' + id,
    method: HttpMethod.GET
  })
}

// 新增客户管理
export function addMember(data) {
  return request({
    url: '/beauty/member',
    method: HttpMethod.POST,
    data: data
  })
}

// 修改客户管理
export function updateMember(data) {
  return request({
    url: '/beauty/member',
    method: HttpMethod.PUT,
    data: data
  })
}

// 删除客户管理
export function delMember(id) {
  return request({
    url: '/beauty/member/' + id,
    method: HttpMethod.DELETE
  })
}

// 客户状态修改
export function changeMemberStatus(memberId, status) {
  return request({
    url: `/beauty/member/changeStatus/${memberId}/${status}`,
    method: HttpMethod.PUT
  })
}

// 支付宝充值金额
export function topUpWithAlipay(memberId, amount) {
  const data = {
    memberId,
    amount
  }
  return request({
    url: `/beauty/member/alipay/topUp`,
    method: HttpMethod.PUT,
    data
  })
}

// 现金充值金额
export function topUpWithCash(memberId, amount) {
  const data = {
    memberId,
    amount
  }
  return request({
    url: `/beauty/member/cash/topUp`,
    method: HttpMethod.PUT,
    data
  })
}

// 支付宝退款
export function refundWithAlipay(memberId, topUpId, amount) {
  const data = {
    topUpId,
    memberId,
    amount
  }
  return request({
    url: `/beauty/member/alipay/refund`,
    method: HttpMethod.PUT,
    data
  })
}

// 现金退款
export function refundWithCash(memberId, topUpId, amount) {
  const data = {
    topUpId,
    memberId,
    amount
  }
  return request({
    url: `/beauty/member/cash/refund`,
    method: HttpMethod.PUT,
    data
  })
}

// 获取客户下拉列表信息
export function getMemberOptionSelect() {
  return request({
    url: '/beauty/member/getOptionSelect',
    method: HttpMethod.GET
  })
}

// 客户密码重置
export function resetMemberPwd(memberId, password) {
  const data = {
    id: memberId,
    password: password
  }
  return request({
    url: '/beauty/member/resetPwd',
    method: HttpMethod.PUT,
    data: data
  })
}
